<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>在平安</title>
<meta name="description" content="中国平安" />
<meta name="keywords" content="中国平安" />
<meta content="width=640, target-densitydpi=320, user-scalable=no" name="viewport" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta content="telephone=no" name="format-detection" />
<link rel="stylesheet" type="text/css" href="css/base.css">
<link rel="stylesheet" type="text/css" href="css/public.css">
<script src="js/zepto.min.js" type="text/javascript"></script>
<script src="js/zepto-touch.js" type="text/javascript"></script>
<script src="js/public.js" type="text/javascript"></script>
<script type="text/javascript">

	$(function(){
		//$("#headImg").attr("src",mpsurl+"/mobile/createPicture/writePicture.do");
		getBaseMessage();
		$(".top-bar-cont span:first-child").on("tap",function(){  //后退功能
			location.href="index.html";
		});
		$("#headImg").on("tap",function(){
			var ua = navigator.userAgent;
			if(ua.indexOf("iPhone")>=0){
				window.location="/objc://photo";
			}else{
				window.pa_app.getPoto();
			}
		});
	});
	function showPhoto(code){
		var nameCn = $("#userName").html();
		var remark = $("#J-StyleName").text();
		var phone = $("#phone").html();
		var imgurl = "/mobile/createPicture/writePicture.do";
		var info = "userRemark="+remark+";userNameCn="+nameCn+";userPhone="+phone+";imageUrl="+imgurl;
		document.cookie = "indexOfUserInfo="+escape(info);
		$("#headImg").attr("src",mpsurl+"/mobile/createPicture/writePicture.do");
	}
	//获取个性签名和图片
	function getBaseMessage(){
		var flag = true;
		if(document.cookie.length > 0){
			var cookieArray = document.cookie.split(";");
			for(var k = 0;k < cookieArray.length;k ++){
				var cookieInfo = cookieArray[k].split("=");
				if(cookieInfo[0] == "indexOfUserInfo"){
					var ss = unescape(cookieInfo[1]).split(";");
					for(var i = 0;i < ss.length;i ++){
						var ii = ss[i].split("=");
						if(ii[0]=="userNameCn"){
							flag = false;
							$("#userName").text(ii[1]);
						}
						if(ii[0]=="userRemark"){
							$("#J-StyleName").text(ii[1]);
						}
						if(ii[0]=="userPhone"){
							$("#phone").text(ii[1]);
						}
						if(ii[0]=="imageUrl"){
							if(ii[1]==""){
								$("#headImg").attr("src",mpsurl+"/mobile/photo/photo.png");
							}else{
								$("#headImg").attr("src",mpsurl+"/mobile/createPicture/writePicture.do");
							}
						}
					}
					
				}
			}
		}
		if(flag){
			$.ajax({
				type:"post",
				url:mpsurl+"/mobile/base/selectUserByEmpId.do",
				dateType:"json",
				data:{method:"selectUserByEmpId"},
				success:function(data){
					data = eval("("+data+")");
					if(data.resultCode=="500600"){
						var userDTO = data.userDTO;
						var nameCn = userDTO.emplName;
						var remark = userDTO.remark;
						var phone = userDTO.phone;
						var imgurl = userDTO.imageUrl;
						$("#userName").html(nameCn);
						$("#J-StyleName").html(remark);
						$("#phone").html(phone);
						if(imgurl==""){
							$("#headImg").attr("src",mpsurl+"/mobile/photo/photo.png");
						}else{
							$("#headImg").attr("src",mpsurl+"/mobile/createPicture/writePicture.do");
						}
						var info = "userRemark="+remark+";userNameCn="+nameCn+";userPhone="+phone+";imageUrl="+imgurl;
						document.cookie = "indexOfUserInfo="+escape(info);
					}
				},
				error: function (XMLHttpRequest, textStatus, errorThrown) {
						//alert(errorThrown);
				}
			});
		}
	}
</script>
</head>

<body>
<div id="wrap">
	<header class="top-bar">
		<div class="top-bar-cont">
			<span class="btn-bar-css btn-bar-back btn-bar-left"><i></i></span>
			<h1>设置</h1>
		</div>
	</header>
	<section id="content">
        <div class="set-content">
            <div class="banner-per">
                <div class="banner-photo">
                    <figure ><img id="headImg" ></figure>
                    <div class="banner-btn-edit" id="J-PerInfoEditBtn"><i></i></div>
                </div>
                <div class="banner-per-info">
                    <h1>欢迎您！<span id="userName"></span></h1>
                </div>
            </div>
            <div class="row-info row-info-readonly list-name-w178">
                <ul class="row-info-list">
                    <li>
                        <div class="info-list-name"></div>
                        <div class="info-list-cont">
                            <div class="tel-way">                            
                                <p class="tel-num" id="phone"></p>
                                <p class="tel-txt">来自PS系统中联系方式</p>
                                <span class="tel-icon"><i></i></span>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="info-list-name">个性签名：</div>
                        <div class="info-list-cont" id="J-StyleName"></div>
                    </li>
                </ul>
            </div>
            <div id="p123"></div>
            <div class="content-btn">
                <div class="btn-css btn-bg-fa4043" id="J-BtnExit">退出登录</div>
            </div>
        </div>
    </section>
</div>
<div class="g-mask" id="GlobalMask">
    <div class="g-mask-bg"></div>
    <div class="g-mask-layout">
        <article class="g-mask-content">        
            <section class="g-mask-cont g-mask-form-cont">
                <textarea class="textarea-css" id="J-TextArea" placeholder="请输入"></textarea>
            </section>            
            <footer class="g-mask-cont-btn">
                <div class="btn-css fn-c-157efb" id="MaskBtnComplete">完成</div>
            </footer>
        </article>
    </div>
</div>
<script>
var styleName = $("#J-StyleName"),
    completeBtn = $("#MaskBtnComplete"),
    mask = $("#GlobalMask"),
    textArea = $("#J-TextArea");
styleName.on("tap", function(){
    textArea.val(styleName.text());
    textArea.focus();
    mask.show();
});
    
completeBtn.on("tap", function(){
    mask.hide();
    styleName.text(textArea.val());
    updMessage(textArea.val());
})
//更新个性签名
function updMessage(message){
	$.ajax({
		type:"post",
		url:mpsurl+"/mobile/base/updateUserRemark.do",
		dateType:"json",
		data:{method:"updateUserRemark",remark:message},
		success:function(data){
			var nameCn = $("#userName").html();
			var remark = message;
			var phone = $("#phone").html();
			var imgurl = $("#headImg").attr("src");
			var info = "userRemark="+remark+";userNameCn="+nameCn+";userPhone="+phone+";imageUrl="+imgurl;
			document.cookie = "indexOfUserInfo="+escape(info);
		},
		error: function (XMLHttpRequest, textStatus, errorThrown) {
		
		}
	});
}
</script>

<div class="g-mask" id="GlobalMask2">
    <div class="g-mask-bg"></div>
    <div class="g-mask-layout">
        <article class="g-mask-content">        
            <section class="g-mask-cont">
                <p>确定退出快乐人吗？</p>
            </section>
            <footer class="g-mask-cont-btn">
                <div class="btn-css btn-left fn-c-999" id="MaskBtnCancel">取消</div>
                <div class="btn-css btn-right fn-c-157efb" id="MaskBtnOk">确定</div>
            </footer>
        </article>
    </div>
</div>
<script>
var exitBtn = $("#J-BtnExit"),
    mask2 = $("#GlobalMask2");
exitBtn.on("tap", function(){
    mask2.show();
})

$("#MaskBtnCancel").on("tap", function(){
    mask2.hide();
})
$("#MaskBtnOk").on("tap", function(){
	try{
		$.ajax({
			url:mpsurl+"/mobile/register/quit.do",
				type:"post",
				dataType:"json",
				success:function(data){ 
				}
		});
	}catch(err){
	
	}
	var ua = navigator.userAgent;
	if(ua.indexOf("iPhone")>=0){
		//window.location="/objc://write&token=''";
		window.location = "/objc://quit";
	}else{
    	window.pa_app.SetToken("");
    	//window.pa_app.exitSys();
    	gotoLocation("/mobile/login.html","");
    }
})
</script>
</body>
</html>
